<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: jxdck662
  Date: 2019/8/8
  Time: 13:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html>
<head></head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>会员登录</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>

<style>
    body{
        margin-top:20px;
        margin:0 auto;
    }
    .carousel-inner .item img{
        width:100%;
        height:300px;
    }


    font {
        color: #3164af;
        font-size: 18px;
        font-weight: normal;
        padding: 0 10px;
    }
</style>
</head>
<body>
<!-- header -->
<div class="container-fluid" >
    <div class="row">
        <div class="col-4"><img src="img/logo2.png" ></div>
        <div class="col-5"><img src="img/header.jpg" ></div>
        <div class="col">
            <c:if test="${sessionScope.user == null}">
                <div class="btn-group float-right" role="group" style="margin-top: 11px;">
                    <a href="LoginServlet"><button type="button" class="btn btn-outline-success">登录</button></a>
                    <a href="register.jsp"><button type="button" class="btn btn-outline-info">注册</button></a>
                    <a href="cart.jsp"><button type="button" class="btn btn-outline-secondary">购物车</button> </a>
                </div>
            </c:if>
            <c:if test="${sessionScope.user != null}">
                <div class="btn-group float-right" role="group" style="margin-top: 11px;">
                    <a href="GetUserServlet"><button type="button" class="btn btn-outline-success">${sessionScope.user.name}</button></a>
                    <a href="LogoutServlet"><button type="button" class="btn btn-outline-info">退出</button></a>
                    <a href="cart.jsp"><button type="button" class="btn btn-outline-secondary">购物车</button> </a>
                    <a href="./GetBusServlet"><button type="button" class="btn btn-outline-danger">我的订单</button> </a>
                </div>
            </c:if>
        </div>
    </div>
</div>
<!-- nav -->
<div class="container-fluid border border-primary" >
    <nav class="navbar navbar-dark bg-dark">
        <nav class="nav nav-pills">
            <c:forEach var="i" begin="0" end="${Items.size}">
                <a class="nav-link text-light" href="items.jsp?pclass=${i}&n=1">${Items.allclass[i]}</a>
            </c:forEach>
            <a class="nav-link text-light" href="index.jsp">首页</a>
        </nav>
        <form class="form-inline my-2 my-lg-0 " action="Search" method="post">
            <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" name="search">
            <button class="btn btn-outline-light my-2 my-sm-0" type="submit">Search</button>
        </form>
    </nav>
</div>


<div class="container-fluid" style="width:100%;background:url('./img/regist_bg.jpg');">
    <div class="row">
        <div class="col-md-2"></div>
        <div class="col-md-8" style="background:#fff;padding:40px 80px;margin:30px;border:7px solid #ccc;">
            <font>会员注册</font>USER REGISTER
            <form class="form-horizontal" style="margin-top:5px;"  id="form">
                <div class="form-group">
                    <label for="username" class="col-sm-2 control-label">用户名</label>
                    <div class="col-sm-6">
                        <input type="text" name="username" class="form-control" id="username" placeholder="请输入用户名">
                        <div role="alert" id="checkun" class="alert" style="display: none"></div>
                    </div>

                </div>
                <div class="form-group">
                    <label for="password" class="col-sm-2 control-label">密码</label>
                    <div class="col-sm-6">
                        <input type="password" name="password" class="form-control" id="password" placeholder="请输入密码">
                        <div role="alert" id="pw" class="alert" style="display: none"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="confirmpwd" class="col-sm-2 control-label">确认密码</label>
                    <div class="col-sm-6">
                        <input type="password" class="form-control" id="confirmpwd" placeholder="请输入确认密码">
                        <div role="alert" id="checkpw" class="alert" style="display: none"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="tel" class="col-sm-2 control-label">电话</label>
                    <div class="col-sm-6">
                        <input type="text" name="tel" class="form-control" id="tel" placeholder="请输入电话">
                    </div>
                </div>
                <div class="form-group">
                    <label for="normal" class="col-sm-2 control-label">类型</label>
                    <div class="col-sm-6">
                        <label class="radio-inline">
                            <input type="radio" name="modify" id="normal" value="normal"> 普通用户
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="modify" id="store" value="store"> 商家
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label for="email" class="col-sm-2 control-label">Email</label>
                    <div class="col-sm-6">
                        <input type="email" name="email" class="form-control" id="email" placeholder="Email">
                        <div role="alert" id="checke" class="alert" style="display: none;"></div>
                    </div>
                </div>
                <div class="form-group">
                    <label for="name" class="col-sm-2 control-label">昵称</label>
                    <div class="col-sm-6">
                        <input type="text" name="name" class="form-control" id="name" placeholder="请输入姓名">
                    </div>
                </div>
                <div class="form-group opt">
                    <label for="inlineRadio1" class="col-sm-2 control-label">性别</label>
                    <div class="col-sm-6">
                        <label class="radio-inline">
                            <input type="radio" name="sex" id="inlineRadio1" value="male"> 男
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="sex" id="inlineRadio2" value="female"> 女
                        </label>
                    </div>
                </div>
                <div class="form-group">
                    <label for="date" class="col-sm-2 control-label">出生日期</label>
                    <div class="col-sm-6">
                        <input type="date" class="form-control" id="date" name="date">
                    </div>
                </div>



                <div class="form-group">
                    <div class="col-sm-offset-2 col-sm-10">
                        <input type="button"  width="100" value="注册" name="submit" border="0" id="submit"
                               style="background: url('./img/register.gif') no-repeat scroll 0 0 rgba(0, 0, 0, 0);
				    height:35px;width:100px;color:white;">
                    </div>
                </div>
            </form>
        </div>

        <div class="col-md-2"></div>

    </div>
    <div class="container-fluid" >
        <nav class="nav justify-content-center">
            <a class="nav-link">关于我们</a>
            <a class="nav-link">联系我们</a>
            <a class="nav-link">招贤纳士</a>
            <a class="nav-link">法律声明</a>
            <a class="nav-link">友情链接</a>
            <a class="nav-link" target="_blank">支付方式</a>
            <a class="nav-link" target="_blank">配送方式</a>
            <a class="nav-link">服务声明</a>
            <a class="nav-link">广告声明</a>
        </nav>
    </div>
    <div style="text-align: center;margin-top: 5px;margin-bottom:20px;">
        Copyright &copy; 2005-2016 传智商城 版权所有
    </div>
    </div>
<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script>
<script type="text/javascript">

    $("document").ready(function () {
        $("#confirmpwd").blur(function () {

            if($("#password").val() != $("#confirmpwd").val()){
                $("#checkpw").fadeIn("slow");
                $("#checkpw").addClass("alert-danger");
                $("#checkpw").text("两次密码不一样");
            }
        });
        $("#submit").click(function () {
            $.ajax({
                type : "POST",
                url: "CheckServlet",
                data : $("#form").serialize(),
                dataType:"text",
                success: function (data) {
                    if(data[0]=='0'){
                        $("#checkun").fadeIn("slow");
                        $("#checkun").addClass("alert-danger");
                        $("#checkun").text("用户名不可用");
                    }
                    if(data[1]=='0'){
                        $("#pw").fadeIn("slow");
                        $("#pw").addClass("alert-danger");
                        $("#pw").text("密码不合规");
                    }
                    if (data[2]='0'){
                        $("#checke").fadeIn("slow");
                        $("#checke").addClass("alert-danger");
                        $("#checke").text("请输入正确邮箱");
                    }
                    if(data=='111'){
                        alert("注册成功")
                        $(window).attr("location","index.jsp")
                    }
                },
                error:function (msg) {
                    console.log(msg)
                }
            });
        });

    });
</script>
</body>
</html>

